<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Module resources</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<hr>

<h1>Module resources</h1>
<ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>This module keeps track of the resources and is used for calculating what can be built with the resources.


<h2><a name="description">Description</a></h2>This module keeps track of the resources and is used for calculating what can be built with the resources. It communicates with the trader module to obtain possible trades.
<h2><a name="index">Function Index</a></h2>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#discardCards-2">discardCards/2</a></td><td>Discard cards when a seven is roll and we have more than seven cards.</td></tr>
<tr><td valign="top"><a href="#getBestBuild-2">getBestBuild/2</a></td><td>Calculates all the possible builds that can be done with a hand and then weights them and returns the best builds.</td></tr>
<tr><td valign="top"><a href="#getBestHand-2">getBestHand/2</a></td><td>Takes a list of hands (generated by the trader) and calls getBestBuild to evaluate them and then compare them to each other.</td></tr>
<tr><td valign="top"><a href="#init-0">init/0</a></td><td>The init function spawn the resources process.</td></tr>
<tr><td valign="top"><a href="#resources-3">resources/3</a></td><td>The process that keeps track of the resources and receives messages from the actuator and devCards processes with instructions.</td></tr>
</table>

<h2><a name="functions">Function Details</a></h2>

<h3 class="function"><a name="discardCards-2">discardCards/2</a></h3>
<div class="spec">
<p><tt>discardCards(Amount, Res) -&gt; {NewRes, DiscardRes}</tt></p>
</div><p>Discard cards when a seven is roll and we have more than seven cards. It first try to discard wood and clay and if that's not enough it discard other resources too. It uses a round robin rule so it discard evenly over the resources it tries to discard.</p>

<h3 class="function"><a name="getBestBuild-2">getBestBuild/2</a></h3>
<div class="spec">
<p><tt>getBestBuild(Res, City) -&gt; {Builds, Value}</tt></p>
</div><p>Calculates all the possible builds that can be done with a hand and then weights them and returns the best builds. City is the number of cities we have built and is used to update the weights according to the strategy used.</p>

<h3 class="function"><a name="getBestHand-2">getBestHand/2</a></h3>
<div class="spec">
<p><tt>getBestHand(Res, City) -&gt; {BestHand, Builds, Value}</tt></p>
</div><p>Takes a list of hands (generated by the trader) and calls getBestBuild to evaluate them and then compare them to each other. City is used when calling getBestBuild</p>

<h3 class="function"><a name="init-0">init/0</a></h3>
<div class="spec">
<p><tt>init() -&gt; Pid</tt></p>
</div><p>The init function spawn the resources process.</p>

<h3 class="function"><a name="resources-3">resources/3</a></h3>
<div class="spec">
<p><tt>resources(Res, Pieces, IDs) -&gt; ok</tt></p>
</div><p>The process that keeps track of the resources and receives messages from the actuator and devCards processes with instructions. It send messages to the trader to get the possible trades.</p>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, May 20 2011, 17:57:30.</i></p>
</body>
</html>
